package com.yao.mybatis.sqlnode;

import com.yao.mybatis.config.XMLScriptParser;
import org.dom4j.Element;

import java.util.List;

/**
 * @author Administrator
 */
public class IfNodeHandler implements NodeHandler{

    @Override
    public void handleNode(Element nodeToHandle, List<SqlNode> contents, XMLScriptParser scriptParser) {
        // 解析test表达式
        String test = nodeToHandle.attributeValue("test");
        //递归解析
        MixedSqlNode mixedSqlNode = scriptParser.parseDynamicTags(nodeToHandle);
        IfSqlNode ifSqlNode = new IfSqlNode(test,mixedSqlNode);
        contents.add(ifSqlNode);
    }
}
